﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MathLib;
using System.Windows.Forms.DataVisualization.Charting;

namespace Demog {
    public partial class ChartForm : Form {

        private Matrix x;
        private Matrix y;
        private Matrix z;

        public ChartForm(Matrix x, Matrix y, Matrix z) {
            this.x = x;
            this.y = y;
            this.z = z;
            InitializeComponent();
        }

        private void DrawPrediction( Matrix notFiltered, Matrix filtered, Matrix realdata, Chart chart1) {
            Series notFilteredSer = chart1.Series.Add("прогноз без фильтрации");
            Series filteredSer = chart1.Series.Add("прогноз с фильтрацией");
            Series realSer = chart1.Series.Add("реальные данные");

            Legend legend = chart1.Legends.Add("Legend");
            notFilteredSer.Legend = filteredSer.Legend = realSer.Legend = "Legend";

            notFilteredSer.ChartType = SeriesChartType.Column;
            filteredSer.ChartType = SeriesChartType.Column;

            for (int i = 0; i < x.NoRows; i++) {
                notFilteredSer.Points.AddXY(i+1, notFiltered[i, 0]);
                realSer.Points.AddXY(i+1, realdata[i, 0]);
               filteredSer.Points.AddXY(i+1, filtered[i, 0]);
        
            }
        }



        private void Chart_Shown(object sender, EventArgs e) {
            DrawPrediction(x, y, z, chart1);
        }

    }
}
